﻿<phone:PhoneApplicationPage
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:wp7cinema_ViewModel="clr-namespace:wp7cinema.ViewModel" xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:im="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions" xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7" x:Class="wp7cinema.TheaterView"
                            SupportedOrientations="Portrait"
                            Orientation="Portrait"
                            mc:Ignorable="d"
                            d:DesignWidth="480"
                            d:DesignHeight="768"
                            shell:SystemTray.IsVisible="True"
                            >
	<phone:PhoneApplicationPage.Resources>
		<Style x:Key="TheaterListItemStyle" TargetType="ListBoxItem">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="ListBoxItem">
						<Grid>
							<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding TNAME}" VerticalAlignment="Top" FontSize="48"/>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style x:Key="RegionListBoxStyle" TargetType="ListBoxItem">
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="BorderThickness" Value="0"/>
			<Setter Property="BorderBrush" Value="Transparent"/>
			<Setter Property="Padding" Value="0"/>
			<Setter Property="HorizontalContentAlignment" Value="Left"/>
			<Setter Property="VerticalContentAlignment" Value="Top"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="ListBoxItem">
						<Border x:Name="LayoutRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal"/>
									<VisualState x:Name="MouseOver"/>
									<VisualState x:Name="Disabled">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="LayoutRoot">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TransparentBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentContainer"/>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="SelectionStates">
									<VisualState x:Name="Unselected"/>
									<VisualState x:Name="Selected">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneAccentBrush}"/>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{Binding Name}" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" FontSize="48" Tag="{Binding Code}"/>
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Storyboard x:Name="ShowRegion">
			<DoubleAnimation Duration="0:0:0.5" To="1" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="RegionPopup" d:IsOptimized="True"/>
			<DoubleAnimation Duration="0:0:0.5" To="1" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="RegionPopup" d:IsOptimized="True"/>
		</Storyboard>
		<Storyboard x:Name="HideRegion">
			<DoubleAnimation Duration="0:0:0.5" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="RegionPopup" d:IsOptimized="True"/>
			<DoubleAnimation Duration="0:0:0.5" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="RegionPopup" d:IsOptimized="True"/>
		</Storyboard>
	</phone:PhoneApplicationPage.Resources>
    
	<!-- Sample code showing usage of ApplicationBar
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="appbar_button1" IconUri="/Images/appbar_button1.png" Text="Button 1"></shell:ApplicationBarIconButton>
            <shell:ApplicationBarIconButton x:Name="appbar_button2" IconUri="/Images/appbar_button2.png" Text="Button 2"></shell:ApplicationBarIconButton>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="menuItem1" Text="MenuItem 1"></shell:ApplicationBarMenuItem>
                <shell:ApplicationBarMenuItem x:Name="menuItem2" Text="MenuItem 2"></shell:ApplicationBarMenuItem>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    -->


	<phone:PhoneApplicationPage.FontFamily>
		<StaticResource ResourceKey="PhoneFontFamilyNormal"/>
	</phone:PhoneApplicationPage.FontFamily>
	<phone:PhoneApplicationPage.FontSize>
		<StaticResource ResourceKey="PhoneFontSizeNormal"/>
	</phone:PhoneApplicationPage.FontSize>
	<phone:PhoneApplicationPage.Foreground>
		<StaticResource ResourceKey="PhoneForegroundBrush"/>
	</phone:PhoneApplicationPage.Foreground>
	<phone:PhoneApplicationPage.DataContext>
		<Binding Path="Main" Source="{StaticResource Locator}"/>
	</phone:PhoneApplicationPage.DataContext>

	<Grid x:Name="LayoutRoot"
	      Background="Transparent">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>

		<Grid.DataContext>
			<wp7cinema_ViewModel:TheaterViewModel/>
		</Grid.DataContext>

		<StackPanel x:Name="TitlePanel"
		            Grid.Row="0"
		            Margin="24,24,0,12">
			<TextBlock x:Name="ApplicationTitle"
			           Text="{Binding ApplicationTitle}"
			           Style="{StaticResource PhoneTextNormalStyle}" />
			<TextBlock x:Name="PageTitle"
			           Text="{Binding PageName}"
			           Margin="-3,-8,0,0"
			           Style="{StaticResource PhoneTextTitle1Style}" />
		</StackPanel>

		<Grid x:Name="ContentGrid"
		      Grid.Row="1">
			<ListBox Margin="0,71,8,0" ItemsSource="{Binding Theaters}" ItemContainerStyle="{StaticResource TheaterListItemStyle}"/>
			<Button x:Name="RegionBtn" HorizontalAlignment="Left" VerticalAlignment="Top" Content="지역선택">
				<Custom:Interaction.Triggers>
					<Custom:EventTrigger EventName="Click">
						<im:ControlStoryboardAction Storyboard="{StaticResource ShowRegion}"/>
					</Custom:EventTrigger>
				</Custom:Interaction.Triggers>
			</Button>
			<Popup x:Name="RegionPopup" Height="284" Margin="122,4,171,0" VerticalAlignment="Top" IsOpen="True" RenderTransformOrigin="0,0">
				<Popup.RenderTransform>
					<CompositeTransform ScaleX="0" ScaleY="0"/>
				</Popup.RenderTransform>
				<Border Background="#FFEFB9B9" CornerRadius="10" VerticalAlignment="Top" HorizontalAlignment="Left" Height="284" Width="186">
					<ListBox x:Name="RegionListBox" ItemsSource="{Binding RegionList}" ItemContainerStyle="{StaticResource RegionListBoxStyle}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="13,0,0,0">
						<Custom:Interaction.Triggers>
							<Custom:EventTrigger EventName="SelectionChanged">
								<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding RegionChangeCommand}" CommandParameter="{Binding SelectedItem, ElementName=RegionListBox}"/>
								<im:ControlStoryboardAction Storyboard="{StaticResource HideRegion}"/>
							</Custom:EventTrigger>
						</Custom:Interaction.Triggers>
					</ListBox>
				</Border>
			</Popup>
		</Grid>
	</Grid>


</phone:PhoneApplicationPage>